/**
 * Created by Administrator on 2014/4/7.
 */
var LevelConsole = function(){
    this.currentScore = 0;
}

LevelConsole.prototype.score = function(arg){
     if(arguments.length==1){
         this.currentScore = arg;
     }else{
         return this.currentScore;
     }
}


LevelConsole.prototype.reset = function(lv){
    var row = 0;
    var lvCfg = null;
    var fillArr = null;
    var tempArr = null;
    var line = 0;
    this.score(0);
    lvCfg = Data["level" + lv];
    if(lvCfg == null)
    {
        trace("通关了!");
        return;
    }
    hintArr = [];
    Data.currentLevel = lv;
    myTimer.reset(lvCfg.time);
    currentLevel = lv;
    alignV = lvCfg.vAlign;
    alignH = lvCfg.hAlign;
    prizeTime = lvCfg.prizeTime;
    prizeScore = lvCfg.prizeScore;
    if(mapArr != null)
    {
        clearMapArr();
    }
    pause = false;
    mapArr = new Array(Data.row);
    row = 0;
    while(row < mapArr.length)
    {
        mapArr[row] = new Array(Data.line);
        line = 0;
        while(line < mapArr[row].length)
        {
            mapArr[row][line] = 0;
            line++;
        }
        row++;
    }
    calculator = new Calculator();
    fillArr = calculator.getAllPicArr(calculator.getPicTypeArr(lvCfg.picNumbers));
    if(lvCfg.minPairs != null)
    {
        calculator.setConnectPicArr(mapArr,fillArr,lvCfg.minPairs);
    }
    //添加边界
    tempArr = [];
    row = 0;
    while(row < Data.line)
    {
        tempArr.push(-1);
        row++;
    }
    mapArr.unshift(tempArr);
    mapArr.push(tempArr.concat());
    row = 0;
    while(row < mapArr.length)
    {
        mapArr[row].unshift(-1);
        mapArr[row].push(-1);
        row++;
    }
    drawMapTile(mapArr,fillArr);
}
